#!/usr/bin/env python
#coding:utf-8

import urllib2
import urllib
import sys

#baidu.com
url = 'http://www.baidu.com/s'
search = [('w', 'python'), ('cl', '3')]

#google.com
#url = 'http://www.google.com/search'
#search = urllib.urlencode(['q', 'python'])
getString = url + "?" + urllib.urlencode(search)
req = urllib2.Request(getString)
fd = urllib2.urlopen(req)
while 1:
    data = fd.read(1024)
    if not len(data):
        break
    sys.stdout.write(data.decode('gbk').encode('utf-8'))
